<?php

namespace App\Contracts\Repositories;

use App\Models\Activity\Activity;
use Illuminate\Database\Eloquent\Collection;

interface ActivityRepository
{
    /**
     * create activity
     *
     * @param Activity $activity
     *
     * @return Activity|null
     */
    public function create(Activity $activity);

    /**
     * Get activity by user id
     *
     * @param string $userId
     *
     * @return Collection|null
     */
    public function findByUserId($userId);

    /**
     * Get group activity by activity id
     *
     * @param string $activityId
     * @param string $groupCode
     *
     * @return Collection|null
     */
    public function findGroupActivityById($activityId, $groupCode);

    /**
     * Get activity by group code
     *
     * @param string $groupCode
     *
     * @return Collection|null
     */
    public function findByGroupCode($groupCode);

    /**
     * get list page data
     *
     * @param string      $groupCode
     * @param int         $category
     * @param string      $sort
     * @param string      $order
     * @param int         $start
     * @param int         $limit
     * @param string|null $keyword
     *
     * @return mixed
     */
    public function findByCategory($groupCode, $category, $sort, $order, $start = 0, $limit = 10, $keyword = null);

    /**
     * get activity count by condition
     *
     * @param array $condition
     *
     * @return integer
     */
    public function countByConditions($condition);

    /**
     * update activity data by condition
     *
     * @param array $updates
     * @param array $conditions
     *
     * @return int
     */
    public function update($updates, $conditions);


    public function delete($conditions);


    public function deleteByIds($ids);

    /**
     * @param $id
     *
     * @return mixed
     */
    public function findOne($id);

    /**
     * get running activity by user id
     *
     * @param $userId
     *
     * @return mixed
     */
    public function findRunningByUserId($userId);

    /**
     * get running activity by model
     *
     * @param string $model
     *
     * @return Collection|null
     */
    public function findRunningModel($model);

    /**
     * get activities by template id
     *
     * @param string $template_id
     * @param null   $field
     *
     * @return mixed
     */
    public function findByTpl($template_id, $field = null);

    /**
     * get activities by model or user id
     *
     * @param string      $model
     * @param null|string $userId
     *
     * @return Collection|null
     */
    public function findByModelOrUserId($model, $userId = null);

    /**
     * 获取已结束的活动
     * @return mixed
     */
    public function getFinishedActivities();

    /**
     * 获取一个月前的活动记录
     * @return mixed
     */
    public function getFinishedActivitiesOneMonthsAgo();

    /**
     * 获取删除的活动
     * @return mixed
     */
    public function getDeletedActivitiesOneMonthAgo();

    /**
     * 统一租户下根据model_id获取统一租户下得所有活动
     * @param $groupCode
     * @param $modelId
     * @param $columns array
     * @return mixed
     */
    public function findByModelIdInSameTenant($groupCode, $modelId, array $columns = ['*']);
}
